<?php
/*type=Service*/

	class Modules_Workspace_Model_GetWorkspace
	{
	
		public $result=array("error"=>"","result"=>0);
		public function Modules_Workspace_Model_GetWorkspace($args=null)
		{
			
			if($args==null)
				return;
			try{
				
				$accounts=Modules_Common_DB_WorkspaceHasUsers::ByUser($_SESSION['id']);
				
				if($accounts==null || count($accounts)<1)
					throw new Exception();
					$this->result["workspace"]=array();
				foreach($accounts as $value)
				{
					$account=new Modules_Common_DB_Workspace($value->workspace_id);	
					$this->result["workspace"][]=array("text"=>$account->name,"value"=>$account->id);
				}
				$this->result["result"]=1;
				
			}
			catch(Exception $e)
			{
				$this->result["result"]=0;
				$this->result["error"]="No valid Workspace";
			}
		}
		public function Init()
		{
			
		}
	}
?>